import java.awt.Point;
import org.rsbot.script.methods.Camera;
import org.rsbot.script.methods.Menu;
import org.rsbot.script.methods.Mouse;
import org.rsbot.script.methods.Objects;
import org.rsbot.script.wrappers.RSModel;
import org.rsbot.script.wrappers.RSObject;

abstract class GuildRanger$ObjectAction extends GuildRanger.Action
{
  private final int id;
  private final String action;
  private Point location;
  private int attempts = 0;

  public GuildRanger$ObjectAction(GuildRanger paramGuildRanger, int paramInt, String paramString) { super(paramGuildRanger, null);
    this.id = paramInt;
    this.action = paramString;
  }

  public void execute()
  {
    if (this.location != null) {
      GuildRanger.access$100(this.this$0).move(this.location, 1, 1);
      if (GuildRanger.access$200(this.this$0)) {
        GuildRanger.access$300(this.this$0).click(this.location, 1, 1, true);
      }
      if (GuildRanger.access$400(this.this$0).doAction(this.action)) {
        this.this$0.sleep(20);
        this.attempts = 0;
      } else if (this.attempts > 8) {
        GuildRanger.access$502(this.this$0, true);
      } else {
        this.attempts += 1;
      }
    } else {
      RSObject localRSObject = GuildRanger.access$600(this.this$0).getNearest(new int[] { this.id });
      if (localRSObject != null)
        if (localRSObject.isOnScreen())
          this.location = localRSObject.getModel().getPoint();
        else
          GuildRanger.access$700(this.this$0).turnTo(localRSObject, 10);
    }
  }

  public void complete()
  {
    this.attempts = 0;
    this.location = null;
  }

  public String getDescription()
  {
    return "Object Action [" + this.action + "]";
  }
}